package com.fsoft.tinhcd.dao;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import com.fsoft.tinhcd.entity.RegionCountry;
import com.fsoft.tinhcd.util.HibernateUtil;

public class RegionCountryDao {
	Session session;

	@SuppressWarnings("unchecked")
	public List<RegionCountry> getListRegionCountry() {
		session = HibernateUtil.getSessionFactory().openSession();
		List<RegionCountry> list = new ArrayList<RegionCountry>();
		Query query = session
				.createQuery("select new com.fsoft.tinhcd.entity.RegionCountry("
						+ "r.regionId,r.regionName,c.countryId,c.countryName)"
						+ " from Region r "
						+ "inner join r.countries c where 1=1");
		list = (List<RegionCountry>) query.list();
		return list;
	}
}
